package com.merak.rebot.config;

import lombok.extern.slf4j.Slf4j;

import java.io.IOException;
import java.io.InputStreamReader;
import java.nio.charset.StandardCharsets;
import java.util.Objects;
import java.util.Properties;

/**
 * @author zhubocheng
 */
@Slf4j
public class LoadConfigContext {

    static Properties configFileProperties = new Properties();

    public static void init(){
        try {
            InputStreamReader reader = new InputStreamReader(Objects.requireNonNull(LoadConfigContext.class.getResourceAsStream("/config.properties")), StandardCharsets.UTF_8);
            configFileProperties.load(reader);
        } catch (IOException e) {
            log.error("load config.properties fail");
            e.printStackTrace();
        }catch (Exception ex){
            log.error(ex.getMessage(),ex);
        }

    }

    public static String getProperties(String key){
        return String.valueOf(configFileProperties.getProperty(key));
    }
}
